Release 10.1A: OpenEdge Development:
Progress 4GL Handbook
Arithmetic expressions and operands
The Progress 4GL supports the set of arithmetic operands described in Table 2–8. You can use these operands to define expressions. You might be familiar with them from other programming languages you have used.
There’s one special thing you need to know when you’re writing expressions involving these operands. Because the Progress 4GL allows the use of a hyphen as a character in a procedure name, variable name, or database field name, it cannot recognize the difference between a hyphen and a minus sign used for subtraction, which are the same keyboard character. For example, there’s no way for the syntax analyzer to tell whether the string
ABC-DEFrepresents a single hyphenated variable or field name, or whether it represent the arithmetic expressionABCminusDEF, involving two fields or variables namedABDandDEF. For this reason, you have to put a space or other white space characters around the “-” character when you use it as a minus sign for subtraction of one number from another. Note that you don’t have to insert a space after a minus sign that precedes a negative number, such as–25. For consistency, the other arithmetic operands also require white space. If you forget to put it in, you’ll get an error, except in the case of the forward slash character. In the case of the slash, if you leave out the white space, Progress interprets the value as a date! So, for example,5/6represents May 6th, not a numeric fraction.
You can add parentheses to such an expression to make the grouping of terms explicit. Otherwise, Progress observes the standard rules of precedence. Multiplication and division are performed before addition and subtraction, and all such calculations are performed before a comparison operation.
The expression following the
IFkeyword compares the CreditLimit field from the current Customer record with two times the value of the Balance field. If the first value is less than the second, then the expression is true and the statement following theTHENkeyword is executed, which displays the string expression Credit Ratio: followed by the value of the CreditLimit divided by the Balance.The
ELSEkeyword is followed by the entireFOR EACH Orderblock, so that block of code, which displays all the Orders of the Customer, is skipped if the expression is true, and executed only if it is false.
![]()
You might notice a couple of things about this display:
- Because the CreditLimit check is in the block of code where the procedure retrieves and displays Customers, it is displayed in the same frame as the Customer information. You can give names to frames to be more specific about the frame in which to display objects, as well as where in the frame each element is displayed. You’ll learn more about naming frames in Chapter 4, " Introducing the OpenEdge AppBuilder."
- Progress understands enough about what is going on here to clear and hide the Order frame if it’s not being displayed for the current Customer (because the CreditLimit to Balance ratio is being displayed instead). This is part of the very powerful default behavior of the language.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |